package com.yanqu.road.server.manger.activity.platform;

import com.yanqu.road.dao.impl.servercenter.ServerInfoDaoImpl;
import com.yanqu.road.entity.servercenter.IntroductionShieldConfig;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.ActivityModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;

import java.util.ArrayList;
import java.util.List;

public class IntroductionShieldMgr extends TempMgr {

    private static List<IntroductionShieldConfig> introductionShieldConfigList;

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        introductionShieldConfigList = new ServerInfoDaoImpl().getIntroductionShieldConfigList();
        notifyGamePlayer();
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }

    public static List<IntroductionShieldConfig> getShieldList(String appId, int clientType) {
        List<IntroductionShieldConfig> dataList = new ArrayList<>();
        for(IntroductionShieldConfig data : introductionShieldConfigList){
            if(data.getAppId().equals(appId) && data.getClientType() == clientType){
                dataList.add(data);
            }
        }
        return dataList;
    }

    /**
    * 描述：通知在线玩家屏蔽
    * 作者：zrq
    * 时间：2023/4/20
    * 参数：

    * 返回值：
    **/
    public static void notifyGamePlayer(){
        List<GamePlayer> playerList = GamePlayerMgr.getCopyPlayerList();
        for(GamePlayer player : playerList){
            player.getModule(ActivityModule.class).syncIntroductionShield();
        }
    }
}
